<header class="entry-header">
		<h1 class="entry-title">Map</h1> 
		<h2 style='display:<?php echo ( isset($rows) && $rows != false ) ? "display":"none";  ?>'>
		<?php if($rows == false){
						$rows = $this->project_m->display_all();
						echo "Sorry! Your Search ".$this->input->post('projectsearch')." did not much in any of our Documents!";
				}
			 
		?>
		</h2>
		
	</header><!-- .entry-header -->

<div class="entry-content">
		<div class='map' id='map-canvas'>			
		</div>
</div><!-- .entry-content -->
	</article><!-- #post-## -->

			
			
		
		</main><!-- #main -->
	</div><!-- #primary -->


	<div id="secondary-right" class="widget-area right-sidebar sidebar">
		
        
	    		

					<aside id="useful-banner-manager-banners-rotation-2" class="widget useful_banner_manager_rotation_widget">            <div id="useful-banner-manager-banners-rotation-2" class="useful_banner_manager_banners_rotation" style="overflow: hidden; width: 200px; height: 167px; margin-left:100px;">
                            <div id="6_useful_banner_manager_banner" class="useful_banner_manager_rotating_banner">
                                            <a href="http://www.westrocksafety.com/about.php" target="_blank" rel="dofollow">
                                    	<img src="http://www.rig-finder.com/wp-content/uploads/useful_banner_manager_banners/6-West Rock Safety.jpg" width="200" height="167" alt="West Rock Safety" />
                                            </a>
                                    </div>
                                <div id="5_useful_banner_manager_banner" class="useful_banner_manager_rotating_banner" style="display: none">
                                            <a href="http://www.westrock-energy.com/" target="_blank" rel="dofollow">
                                    	<img src="http://www.rig-finder.com/wp-content/uploads/useful_banner_manager_banners/5-West Rock Energy Consultant.jpg" width="200" height="167" alt="West Rock Energy Consultant" />
                                            </a>
                                    </div>
                                <div id="4_useful_banner_manager_banner" class="useful_banner_manager_rotating_banner" style="display: none">
                                            <a href="http://www.bulldoghotshot.ca/" target="_blank" rel="dofollow">
                                    	<img src="http://www.rig-finder.com/wp-content/uploads/useful_banner_manager_banners/4-BullDog Hot Shot.jpg" width="200" height="167" alt="BullDog Hot Shot" />
                                            </a>
                                    </div>
                                <div id="3_useful_banner_manager_banner" class="useful_banner_manager_rotating_banner" style="display: none">
                                            <a href="#" target="_blank" rel="dofollow">
                                    	<img src="http://www.rig-finder.com/wp-content/uploads/useful_banner_manager_banners/3-ads_fracnotice.png" width="200" height="167" alt="FracNotice" />
                                            </a>
                                    </div>
                                <div id="2_useful_banner_manager_banner" class="useful_banner_manager_rotating_banner" style="display: none">
                                            <a href="http://www.flarenotice.com/" target="_blank" rel="dofollow">
                                    	<img src="http://www.rig-finder.com/wp-content/uploads/useful_banner_manager_banners/2-ads_flarenotice.png" width="200" height="167" alt="Flare Notice" />
                                            </a>
                                    </div>
                                <div id="1_useful_banner_manager_banner" class="useful_banner_manager_rotating_banner" style="display: none">
                                            <a href="http://www.conroyhockey.ca/" target="_blank" rel="dofollow">
                                    	<img src="http://www.rig-finder.com/wp-content/uploads/useful_banner_manager_banners/1-ads_conroyhockey.png" width="200" height="167" alt="Conroy Hockey" />
                                            </a>
                                    </div>
                            </div>
            <script type="text/javascript">
            jQuery(function($){
                $(document).ready(function(){
                    var useful_banner_manager_banners_rotation_block = "useful-banner-manager-banners-rotation-2";
                    var interval_between_rotations = 6000;

                    if($("#"+useful_banner_manager_banners_rotation_block+" .useful_banner_manager_rotating_banner").length>1){
                        setTimeout("useful_banner_manager_rotate_banners('"+useful_banner_manager_banners_rotation_block+"',"+interval_between_rotations+")",interval_between_rotations);
                    }
                });
            });
            </script>
            </aside>		        	</div><!-- #secondary -->
</section>
<style>
	 #map-canvas {
        height: 500px;
        margin: 0px auto;
        padding: 0px;
      }
</style>
<script src="//code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp"></script>
<script type='text/javascript'>

var map;
var zoomLimit = 2;
var cl_markers = [
	<?php foreach($rows as $data): ?>
	{
	company_name:"<?php echo $data->company_name; ?>",
    project_name: "<?php echo $data->project_name ?>",
    lat: <?php echo $data->lat ?>,
    lng:  <?php echo $data->lng ?>,
    address: "<?php echo $data->comp_address ?>",
	icon:"<?php echo site_url($data->project_icon); ?>",
	},
	<?php endforeach; ?>
];

function _newGoogleMapsMarker(param) {
    var r = new google.maps.Marker({
        map: param._map,
        position: new google.maps.LatLng(param._lat, param._lng),
        title: param._head,
		icon:param._icon,
		animation: google.maps.Animation.DROP,
    });
    if (param._data) {
        google.maps.event.addListener(r, 'click', function() {
            // this -> the marker on which the onclick event is being attached
            if (!this.getMap()._infoWindow) {
                this.getMap()._infoWindow = new google.maps.InfoWindow();
            }
            this.getMap()._infoWindow.close();
            this.getMap()._infoWindow.setContent(param._data);
            this.getMap()._infoWindow.open(this.getMap(), this);
        });
    }
    return r;
}

function init() {
    var mO = {
        center: new google.maps.LatLng(0,0),
        zoom: zoomLimit,
        streetViewControl: true,
        mapTypeControl: true,
        mapTypeId: google.maps.MapTypeId.ROADMAP
    };
    map = new google.maps.Map(document.getElementById("map-canvas"), mO);
	
	
	
    for (var a = 0; a < cl_markers.length; a++) {
        
		var tmpLat = cl_markers[a].lat;
        var tmpLng = cl_markers[a].lng;
		var tmpCompName = cl_markers[a].company_name;
        var tmpName = cl_markers[a].project_name;
        var tmpAdr = cl_markers[a].address;
		var tmpIcon = cl_markers[a].icon;
        var marker = _newGoogleMapsMarker({
			_icon:tmpIcon,
            _map: map,
            _lat: tmpLat,
            _lng: tmpLng,
            _head: tmpName ,
            _data: '<div class="bg">\
			<h1 class="compname">' + tmpCompName + '</h1>\
			<h2 class="title">' + tmpName + '</h2>\
			<h3 class="address">' + tmpAdr + '</h3>\
        </div>'
        });
    } // end loop ..
	
}

window.onload = init;


</script>